package com.hspedu.seckill.util;

import org.springframework.util.StringUtils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 验证手机号格式工具类
 */
public class ValidatorUtil {

    private static final Pattern MOBILE_PATTEN = Pattern.compile("^(13[0-9]|14[5|7]|15[0|1|2|3|5|6|7|8|9]|18[0|1|2|3|5|6|7|8|9])\\d{8}$");

    public static boolean isMobile(String mobile){
        if (!StringUtils.hasText(mobile)){
            return false;
        }
        Matcher matcher = MOBILE_PATTEN.matcher(mobile);
        return matcher.matches();
    }

}
